<template>
	<el-main>
		<el-empty :image-size="200" description="暂无待考记录" v-if="list.length==0"></el-empty>
		<el-row :gutter="15">
			<el-col :xl="6" :lg="6" :md="8" :sm="12" :xs="24" v-for="item in list" :key="item.recordId">
				<el-card class="task task-item" shadow="hover" @click="textExam(item)">
					<h2>{{ item.title }}</h2>
					<ul>
						<li>
							<h4>开考时间
								<div v-if="item.openStatus=='true'" style="float: right">
									<el-tag style="float:right;" type="success">开考</el-tag>
								</div>
								<div v-else style="float: right">
									<el-tag style="float:right;" v-if="item.status=='2'" type="danger">已考</el-tag>
									<el-tag style="float:right;" v-else-if="item.status=='1'" type="info">阅卷</el-tag>
									<el-tag style="float:right;" v-else type="warning">待考</el-tag>
								</div>
							</h4>
							<p class="info-title">{{ item.beginTime }}~{{item.endTime}}</p>
						</li>
						<li>
							<h4>主考部门
								<el-tag style="float:right;" v-if="item.isOpen=='0'">闭卷</el-tag>
								<el-tag style="float:right;" v-if="item.isOpen=='1'" type="success">开卷</el-tag></h4>
							<p>{{ item.deptName }}</p>
						</li>
						<li>
							<div class="info-title" :title="item.remark">{{ item.remark }}</div>
						</li>
					</ul>
				</el-card>
			</el-col>
		</el-row>
	</el-main>
	<examDetails v-if="dialog.detailsSave" ref="detailsDialog" @closed="dialog.detailsSave=false"></examDetails>
</template>

<script>
import examDetails from "./examdetails";
export default {
	name: 'My Exam List',
	components: {
		examDetails
	},
	provide() {
		return {
			list: this.list
		}
	},
	data() {
		return {
			dialog: {
				save: false,
				detailsSave:false
			},
			list: []
		}
	},
	mounted() {
		this.getMyExamTestList();
	},
	methods: {
		async getMyExamTestList() {
			var res = await this.$API.office.exam.getMyExamTestList.get();
			if(res.code==200)
			{
				if(res.data)
				{
					this.list = res.data;
				}
			}
		},
		textExam(item)
		{
			if(item.openStatus=="true")
			{
				this.$nextTick(() => {
					window.open('/#/office/exam/myexam/testexma?recordId='+item.recordId+"&ddtab=true", "_blank");
				})
			}else
			{
				if(item.status=="1")
				{
					this.$alert("阅卷中", "提示", {type: 'error'})
				}else if(item.status=="2")
				{
					this.dialog.detailsSave = true
					this.$nextTick(() => {
						this.$refs.detailsDialog.open().setData(item)
					})
				}else
				{
					this.$alert("未开考,请等待！", "提示", {type: 'error'})
				}
			}
		}
	}
}
</script>

<style scoped>
.task {
	height: 200px;
}

.task-item h2 {
	font-size: 15px;
	color: #3c4a54;
	padding-bottom: 15px;
}

.task-item li {
	list-style-type: none;
	margin-bottom: 10px;
}

.task-item li h4 {
	font-size: 12px;
	font-weight: normal;
	color: #999;
}

.task-item li p {
	margin-top: 5px;
}

.task-item .bottom {
	border-top: 1px solid #EBEEF5;
	text-align: right;
	padding-top: 10px;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.task-add {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	cursor: pointer;
	color: #999;
}

.task-add:hover {
	color: #409EFF;
}

.task-add i {
	font-size: 30px;
}

.task-add p {
	font-size: 12px;
	margin-top: 20px;
}

.dark .task-item .bottom {
	border-color: var(--el-border-color-light);
}

.info-title {
	width: 100%;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	cursor: pointer;
}
</style>
